using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using FBGraph.Demos.AspNetMvc.Models.View.Groups;

namespace FBGraph.Demos.AspNetMvc.Controllers
{
    public class GroupsController : BaseController
    {
        public ActionResult Index()
        {
            var groups = FbContext.Groups.GetFor("me");

            var model = new IndexData
            {
                Groups = groups
            };

            return View(model);
        }

        public ActionResult Detail(Object id)
        {
            using (FbContext.StartAsync())
            {
                var group = FbContext.Groups.Get(id);
                var feed = FbContext.Feed.GetFor(id);
                var members = FbContext.Groups.Members.GetFor(id);

                FbContext.CompleteAsync();

                var model = new DetailData
                {
                    Group = group,
                    Feed = feed,
                    Members = members
                };

                return View(model);
            }
        }
    }
}